package com.example.prom.ok.y2022.controller.kyc3;

public class LoqateTest {
    static public java.util.Hashtable[] Capture_Interactive_Find_v1_10(String Key, String Text, Boolean IsMiddleware, String Container, String Origin, String Countries, Integer Limit, String Language, Boolean Bias, String Filters, String GeoFence) throws Exception
    {

        String requestUrl = new String();
        String key = new String();
        String value = new String();

        //Build the url
        requestUrl = "https://api.addressy.com/Capture/Interactive/Find/v1.10/xmla.ws?";
        requestUrl += "&Key=" + java.net.URLEncoder.encode(Key);
        requestUrl += "&Text=" + java.net.URLEncoder.encode(Text);
        requestUrl += "&IsMiddleware=" + java.net.URLEncoder.encode(IsMiddleware.toString());
        requestUrl += "&Container=" + java.net.URLEncoder.encode(Container);
        requestUrl += "&Origin=" + java.net.URLEncoder.encode(Origin);
        requestUrl += "&Countries=" + java.net.URLEncoder.encode(Countries);
        requestUrl += "&Limit=" + java.net.URLEncoder.encode(Limit.toString());
        requestUrl += "&Language=" + java.net.URLEncoder.encode(Language);
        requestUrl += "&Bias=" + java.net.URLEncoder.encode(Bias.toString());
        requestUrl += "&Filters=" + java.net.URLEncoder.encode(Filters);
        requestUrl += "&GeoFence=" + java.net.URLEncoder.encode(GeoFence);

        //Get the data
        java.net.URL url = new java.net.URL(requestUrl);
        java.io.InputStream stream = url.openStream();
        javax.xml.parsers.DocumentBuilder docBuilder = javax.xml.parsers.DocumentBuilderFactory.newInstance().newDocumentBuilder();
        org.w3c.dom.Document dataDoc = docBuilder.parse(stream);

        //Get references to the schema and data
        org.w3c.dom.NodeList schemaNodes = dataDoc.getElementsByTagName("Column");
        org.w3c.dom.NodeList dataNotes = dataDoc.getElementsByTagName("Row");

        //Check for an error
        if (schemaNodes.getLength()==4 && schemaNodes.item(0).getAttributes().getNamedItem("Name").getNodeValue().equals("Error"))
        {
            throw new Exception(dataNotes.item(0).getAttributes().getNamedItem("Description").getNodeValue());
        };

        //Work though the items in the response
        java.util.Hashtable[] results = new java.util.Hashtable[dataNotes.getLength()];
        for (int rowCounter=0; rowCounter<dataNotes.getLength(); rowCounter++)
        {
            java.util.Hashtable rowData = new java.util.Hashtable();
            for (int colCounter=0; colCounter<schemaNodes.getLength(); colCounter++)
            {
                key = (String)schemaNodes.item(colCounter).getAttributes().getNamedItem("Name").getNodeValue();
                if(dataNotes.item(rowCounter).getAttributes().getNamedItem(key)==null)
                {
                    value="";
                }
                else
                {
                    value = (String)dataNotes.item(rowCounter).getAttributes().getNamedItem(key).getNodeValue();
                };
                rowData.put (key, value);
            }
            results[rowCounter] = rowData;
        }

        //Return the results
        return results;
    }

    static public java.util.Hashtable[] Capture_Interactive_Retrieve_v1_20(String Key, String Id, String Field1Format, String Field2Format, String Field3Format, String Field4Format, String Field5Format, String Field6Format, String Field7Format, String Field8Format, String Field9Format, String Field10Format, String Field11Format, String Field12Format, String Field13Format, String Field14Format, String Field15Format, String Field16Format, String Field17Format, String Field18Format, String Field19Format, String Field20Format) throws Exception
    {

        String requestUrl = new String();
        String key = new String();
        String value = new String();

        //Build the url
        requestUrl = "https://api.addressy.com/Capture/Interactive/Retrieve/v1.20/xmla.ws?";
        requestUrl += "&Key=" + java.net.URLEncoder.encode(Key);
        requestUrl += "&Id=" + java.net.URLEncoder.encode(Id);
        requestUrl += "&Field1Format=" + java.net.URLEncoder.encode(Field1Format);
        requestUrl += "&Field2Format=" + java.net.URLEncoder.encode(Field2Format);
        requestUrl += "&Field3Format=" + java.net.URLEncoder.encode(Field3Format);
        requestUrl += "&Field4Format=" + java.net.URLEncoder.encode(Field4Format);
        requestUrl += "&Field5Format=" + java.net.URLEncoder.encode(Field5Format);
        requestUrl += "&Field6Format=" + java.net.URLEncoder.encode(Field6Format);
        requestUrl += "&Field7Format=" + java.net.URLEncoder.encode(Field7Format);
        requestUrl += "&Field8Format=" + java.net.URLEncoder.encode(Field8Format);
        requestUrl += "&Field9Format=" + java.net.URLEncoder.encode(Field9Format);
        requestUrl += "&Field10Format=" + java.net.URLEncoder.encode(Field10Format);
        requestUrl += "&Field11Format=" + java.net.URLEncoder.encode(Field11Format);
        requestUrl += "&Field12Format=" + java.net.URLEncoder.encode(Field12Format);
        requestUrl += "&Field13Format=" + java.net.URLEncoder.encode(Field13Format);
        requestUrl += "&Field14Format=" + java.net.URLEncoder.encode(Field14Format);
        requestUrl += "&Field15Format=" + java.net.URLEncoder.encode(Field15Format);
        requestUrl += "&Field16Format=" + java.net.URLEncoder.encode(Field16Format);
        requestUrl += "&Field17Format=" + java.net.URLEncoder.encode(Field17Format);
        requestUrl += "&Field18Format=" + java.net.URLEncoder.encode(Field18Format);
        requestUrl += "&Field19Format=" + java.net.URLEncoder.encode(Field19Format);
        requestUrl += "&Field20Format=" + java.net.URLEncoder.encode(Field20Format);

        //Get the data
        java.net.URL url = new java.net.URL(requestUrl);
        java.io.InputStream stream = url.openStream();
        javax.xml.parsers.DocumentBuilder docBuilder = javax.xml.parsers.DocumentBuilderFactory.newInstance().newDocumentBuilder();
        org.w3c.dom.Document dataDoc = docBuilder.parse(stream);

        //Get references to the schema and data
        org.w3c.dom.NodeList schemaNodes = dataDoc.getElementsByTagName("Column");
        org.w3c.dom.NodeList dataNotes = dataDoc.getElementsByTagName("Row");

        //Check for an error
        if (schemaNodes.getLength()==4 && schemaNodes.item(0).getAttributes().getNamedItem("Name").getNodeValue().equals("Error"))
        {
            throw new Exception(dataNotes.item(0).getAttributes().getNamedItem("Description").getNodeValue());
        };

        //Work though the items in the response
        java.util.Hashtable[] results = new java.util.Hashtable[dataNotes.getLength()];
        for (int rowCounter=0; rowCounter<dataNotes.getLength(); rowCounter++)
        {
            java.util.Hashtable rowData = new java.util.Hashtable();
            for (int colCounter=0; colCounter<schemaNodes.getLength(); colCounter++)
            {
                key = (String)schemaNodes.item(colCounter).getAttributes().getNamedItem("Name").getNodeValue();
                if(dataNotes.item(rowCounter).getAttributes().getNamedItem(key)==null)
                {
                    value="";
                }
                else
                {
                    value = (String)dataNotes.item(rowCounter).getAttributes().getNamedItem(key).getNodeValue();
                };
                rowData.put (key, value);
            }
            results[rowCounter] = rowData;
        }

        //Return the results
        return results;
    }

}
